package com.yoki.cloud.common.protocol.radius.attribute.attr.check;

import com.yoki.cloud.common.protocol.radius.attribute.attr.type.IntegerTypeAttr;
import lombok.Getter;

/**
 * @author Sky$
 * @Description: TODO
 * @date 2018/1/15$ 14:54$
 */
public class FramedProtocolAttr extends IntegerTypeAttr {

    public static final int ATTR_TYPE = 7;

    @Override
    public int getAttrType() {
        return ATTR_TYPE;
    }

    public FramedProtocolTypeEnum getFramedProtocolType() {
        return FramedProtocolTypeEnum.getByValue(this.value);
    }

    enum FramedProtocolTypeEnum {

        PPP(1, "PPP"),
        SLIP(2, "SLIP"),
        /**
         * AppleTalk Remote Access Protocol
         */
        ARAP(3, "AppleTalk Remote Access Protocol (ARAP)");

        @Getter
        private int value;
        @Getter
        private String name;

        FramedProtocolTypeEnum(int value, String name) {
            this.value = value;
            this.name = name;
        }

        public static FramedProtocolTypeEnum getByValue(Integer value) {
            if (null == value) {
                throw new IllegalArgumentException();
            }
            FramedProtocolTypeEnum[] enums = FramedProtocolTypeEnum.values();
            for (FramedProtocolTypeEnum e : enums) {
                if (e.getValue() == value.intValue()) {
                    return e;
                }
            }
            return null;
        }

    }

}


